import { IsDefined, IsNotEmpty, IsString } from "class-validator";
import { BaseEntity } from "../BaseEntity";
import { Model } from "sequelize";

export default class CatEntity extends BaseEntity {
  id?: number;

  @IsString()
  public saleUnit: string;

  @IsString()
  public chipCode: string;

  @IsString()
  public variety: string;

  @IsString()
  @IsDefined()
  @IsNotEmpty()
  public name: string;

  @IsString()
  public color: string;

  @IsString()
  public sex: string;

  @IsString()
  public brithday: string;

  @IsString()
  public hair: string;

  @IsString()
  public host: string;

  @IsString()
  public homeName: string;

  @IsString()
  public imgUrl: string;

  @IsString()
  public shelfNum: string;

  @IsString()
  public petStatus: string;

  /**
   * 父母
   */
  @IsString()
  public parent: string;

  /**
   * 等级
   */
  @IsString()
  public grade: string;

  /**
   * 第几代
   */
  @IsString()
  public generation: string;

  /**
   * 宠物类型
   * 1: 猫
   * 2: 狗
   */
  @IsString()
  @IsNotEmpty()
  @IsDefined()
  public petType: string;

  /**
   * 品牌
   */
  @IsString()
  public brand: string;

  public static transform(plainObject: object): CatEntity {
    return super.baseTransform(CatEntity, plainObject);
  }
}

export interface ICatModel extends Model<CatEntity> {}

export const importFieldMap = {
  芯片编号: "chipCode",
  品种: "variety",
  猫名字: "name",
  花色: "color",
  性别: "sex",
  出生日期: "brithday",
  长短毛: "hair",
  主人名字: "host",
  猫舍: "catteryId",
  货架号数: "shelfNum",
  售出: "saleUnit",
  图片: "imgUrl",
};
